Skip to content

Revert "http: do not emit socket errors after complete response"#64511

Merged
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
mcollina:revert-17163ead
Jul 15, 2026
Merged

Revert "http: do not emit socket errors after complete response"#64511
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
mcollina:revert-17163ead

Conversation

@mcollina

@mcollina mcollina commented Jul 15, 2026

Copy link
Copy Markdown
Member

This reverts commit 17163ea / #64278.

This landed too quickly #64278 (comment). Alternative to #64507.

This reverts commit 17163ea.

Signed-off-by: Matteo Collina <hello@matteocollina.com>
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/http
  • @nodejs/net

@nodejs-github-bot nodejs-github-bot added http Issues or PRs related to the http subsystem. needs-ci PRs that need a full CI run. labels Jul 15, 2026
@mcollina
mcollina requested review from lpinca and pimterry July 15, 2026 07:07
@mcollina mcollina added the fast-track PRs that do not need to wait for 72 hours to land. label Jul 15, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Fast-track has been requested by @mcollina. Please 👍 to approve.

@mcollina

Copy link
Copy Markdown
Member Author

@pimterry @lpinca PTAL

@pimterry

Copy link
Copy Markdown
Member

Fair enough, I'm on board. #64507 has indeed hit CI issues with Mac, so it doesn't look like it's the easy tiny quick fix I was hoping. I'll it finish it up on top of this afterwards to bring the fix back correctly.

@pimterry pimterry added the request-ci Add this label to start a Jenkins CI on a PR. label Jul 15, 2026
@Archkon

Archkon commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Fair enough, I'm on board. #64507 has indeed hit CI issues with Mac, so it doesn't look like it's the easy tiny quick fix I was hoping. I'll it finish it up on top of this afterwards to bring the fix back correctly.

I kinda get to realize this, this maybe the problem with test code not nodejs lib code.Could you check my suggestion on #64507 thread? I think your fix is correct direction

@ShogunPanda ShogunPanda left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jul 15, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@mcollina mcollina added the request-ci Add this label to start a Jenkins CI on a PR. label Jul 15, 2026
@mcollina

Copy link
Copy Markdown
Member Author

@Archkon can you please send this change again so we can reapply it/rediscuss it? Sorry.

@Archkon

Archkon commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

@Archkon can you please send this change again so we can reapply it/rediscuss it? Sorry.

I just think the problem with the test code where

assert.strictEqual(err.code, 'ECONNRESET');

in test-http-client-complete-response-open-request-reset.js

should be changed to like this

    assert.strictEqual(err.syscall, 'write');
    switch (err.code) {
    case 'ECONNRESET':
    case 'ECONNABORTED':
    case 'EPIPE':
      break;
    default:
      assert.fail(`Unexpected error code ${err.code}`);
  }

@Archkon

Archkon commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

@Archkon can you please send this change again so we can reapply it/rediscuss it? Sorry.

I just think the problem with the test code where

assert.strictEqual(err.code, 'ECONNRESET');

in test-http-client-complete-response-open-request-reset.js

should be changed to like this

    assert.strictEqual(err.syscall, 'write');
    switch (err.code) {
    case 'ECONNRESET':
    case 'ECONNABORTED':
    case 'EPIPE':
      break;
    default:
      assert.fail(`Unexpected error code ${err.code}`);
  }

Which you could find the similar test code in
test/parallel/test-http-destroyed-socket-write2.js

    switch (er.code) {
      // This is the expected case
      case 'ECONNRESET':
        break;

      // On Windows, this sometimes manifests as ECONNABORTED
      case 'ECONNABORTED':
        break;

      // This test is timing sensitive so an EPIPE is not out of the question.
      // It should be infrequent, given the 50 ms timeout, but not impossible.
      case 'EPIPE':
        break;

      default:
        // Write to a torn down client should RESET or ABORT
        assert.fail(`Unexpected error code ${er.code}`);
    }

I just guess that the macos would differ to respond a error code.

I was wrongly be confused this when I first met the macos test failed and I change checking whether response completed to just check whether response exist.That is my bad,sorry

@Archkon

Archkon commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

@pimterry @mcollina Could you check this and I have no macos device to test. Thanks!

@Archkon can you please send this change again so we can reapply it/rediscuss it? Sorry.

I just think the problem with the test code where

assert.strictEqual(err.code, 'ECONNRESET');

in test-http-client-complete-response-open-request-reset.js
should be changed to like this

    assert.strictEqual(err.syscall, 'write');
    switch (err.code) {
    case 'ECONNRESET':
    case 'ECONNABORTED':
    case 'EPIPE':
      break;
    default:
      assert.fail(`Unexpected error code ${err.code}`);
  }

Which you could find the similar test code in test/parallel/test-http-destroyed-socket-write2.js

    switch (er.code) {
      // This is the expected case
      case 'ECONNRESET':
        break;

      // On Windows, this sometimes manifests as ECONNABORTED
      case 'ECONNABORTED':
        break;

      // This test is timing sensitive so an EPIPE is not out of the question.
      // It should be infrequent, given the 50 ms timeout, but not impossible.
      case 'EPIPE':
        break;

      default:
        // Write to a torn down client should RESET or ABORT
        assert.fail(`Unexpected error code ${er.code}`);
    }

I just guess that the macos would differ to respond a error code.

I was wrongly be confused this when I first met the macos test failed and I change that to just check whether response exist.That is my bad,sorry

@codecov

codecov Bot commented Jul 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.24%. Comparing base (7a11a9b) to head (fd66d5a).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #64511      +/-   ##
==========================================
- Coverage   90.24%   90.24%   -0.01%     
==========================================
  Files         739      739              
  Lines      241669   241655      -14     
  Branches    45543    45545       +2     
==========================================
- Hits       218087   218072      -15     
+ Misses      15150    15114      -36     
- Partials     8432     8469      +37     
Files with missing lines Coverage Δ
lib/_http_client.js 97.61% <100.00%> (-0.03%) ⬇️

... and 36 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jul 15, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@pimterry pimterry added the commit-queue Add this label to land a pull request using GitHub Actions. label Jul 15, 2026
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Jul 15, 2026
@nodejs-github-bot
nodejs-github-bot merged commit 34c28d5 into nodejs:main Jul 15, 2026
87 checks passed
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Landed in 34c28d5

Archkon added a commit to Archkon/node that referenced this pull request Jul 17, 2026
A transport write error can be delivered before a readable event from
the same poll cycle. Writable error handling then destroys both sides of
the socket before the HTTP parser can consume an already-sent response.

Defer native write errors that do not carry protocol-specific details.
After pending reads run, suppress the error only when the request write
and response parse are both complete. Continue reporting open writes,
truncated responses, user destroy errors, and TLS protocol errors.

Follow-up to: nodejs#64507
Original PR Refs: nodejs#64278
Fixes: nodejs#64272
Refs:nodejs#64511
Refs: libuv/libuv#5196
Refs: nodejs#64507 (comment)
Refs: nodejs#64511 (comment)

Signed-off-by: Archkon <180910180+Archkon@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fast-track PRs that do not need to wait for 72 hours to land. http Issues or PRs related to the http subsystem. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants